package com.example.demo.mapper;

import com.example.demo.domain.dao.HbutEmptyClassRoom;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

/**
 * @author lizijian
 */
@Mapper
@Repository
public interface EmptyClassRoomDao {



    @Insert("<script>INSERT INTO hbut_empty_classroom (building_id,week,day,lesson,classroom) VALUES " +
            "<foreach collection='hbutEmptyClassRooms' item='item' separator=',' >" +
            "(#{item.buildingId},#{item.week},#{item.day},#{item.lesson},#{item.classroom}) </foreach></script>")
    void addEmptyClassRoom(@Param("hbutEmptyClassRooms") ArrayList<HbutEmptyClassRoom> hbutEmptyClassRooms);


    @Delete("TRUNCATE TABLE hbut_empty_classroom")
    void deleteEmptyClassRoom();


    @Results({@Result(column = "building_id",property = "buildingId"),@Result(column = "update_time",property = "updateTime")})
    @Select("SELECT * FROM hbut_empty_classroom WHERE building_id =#{buildingId} AND `week`=#{week} AND `day` =#{day} AND lesson =#{lesson}")
    List<HbutEmptyClassRoom> getEmptyClassRoom(@Param("buildingId") Integer buildingId, @Param("week") Integer week,
                                               @Param("day") Integer day,@Param("lesson") Integer lesson);


}
